package com.lkl.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lkl.project.common.ErrorCode;
import com.lkl.project.exception.BusinessException;
import com.lkl.project.mapper.InterfaceInfoMapper;
import com.lkl.longapicommon.model.entity.InterfaceInfo;
import com.lkl.project.service.InterfaceInfoService;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


/**
 * @author 20662
 * @description 针对表【interface_info(接口信息)】的数据库操作Service实现
 * @createDate 2023-11-12 15:51:00
 */
@Service
public class InterfaceInfoServiceImpl extends ServiceImpl<InterfaceInfoMapper, InterfaceInfo>
        implements InterfaceInfoService {

    @Resource
    private InterfaceInfoMapper interfaceInfoMapper;


    @Override
    public void validInterfaceInfo(InterfaceInfo interfaceInfo, boolean add) {


        if (interfaceInfo == null) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        //获取接口信息对象的名称
        String name = interfaceInfo.getName();


        //创建时，所有参数必须非空
//        if (add) {
//            if (Stringutils.isAnyBlank(name)) {
//                throw new BusinessException(ErrorCode.PARAMS_ERROR);
//            }
//        }
////        如果接口名称不为空且长度大于50，抛出参数错误的异常，错误信息为"名称过长"
////        本期写成<50，（没有解决），第二期视频中解决了
//        if (stringutils.isNotBlank(name) && name.length() > 50) {
//            throw new BusinessException(ErrorCode.PARAMS_ERROR, "内容过长");
//        }
    }
}




